package com.ruoyi.web.controller.admin;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BdmComment;
import com.ruoyi.system.domain.dto.BdmCommentHistoryDto;
import com.ruoyi.system.domain.vo.BdmCommentVo;
import com.ruoyi.system.service.IBdmCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 评论Controller
 * 
 * @author ruoyi
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/system/comment")
public class BdmCommentController extends BaseController
{
    @Autowired
    private IBdmCommentService bdmCommentService;

    /**
     * 查询评论列表
     * @return {@link BdmCommentVo}
     */
    @GetMapping("/list")
    public TableDataInfo list(BdmCommentHistoryDto bdmCommentHistoryDto)
    {
        startPage();
        List<BdmCommentVo> list = bdmCommentService.adminHistory(bdmCommentHistoryDto);
        return getDataTable(list);
    }


    /**
     * 新增评论
     */
    @Log(title = "评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BdmComment bdmComment)
    {
        return toAjax(bdmCommentService.insertBdmComment(bdmComment));
    }

    /**
     * 修改评论
     */
    @Log(title = "评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BdmComment bdmComment)
    {
        return toAjax(bdmCommentService.updateBdmComment(bdmComment));
    }

    /**
     * 删除评论
     */
    @Log(title = "评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bdmCommentService.deleteBdmCommentByIds(ids));
    }
}
